<?php

class DownloadController extends AppController {

    public function index($codigo, $musica) {
        $datos = Load::model('musica')->datosXmlGoear($codigo);
        //$datos = array("titulo" => "secure", "artista" => "secure", "url" => "secure");
        if ($datos) {
            $datos['tituloMusica'] = str_replace("-", " ", $musica);
            $this->datos = $datos;
            $this->urlDescarga = $datos['urlDescarga'];
            //$this->urlDescarga = "http://www.goear.com/plimiter.php?f=" . $codigo;
        } else {
            $this->musicaRelacionada = 'music';
            $musica = str_replace("-", "+", $musica);
            $link = '<a href="/youtube/lista/' . $musica . '">click aqui</a>';
            Flash::error("La musica no se encuentra disponible, busque de nuevo o " . $link . "");
        }
        $this->idMusica = $codigo;
        //http://www.goear.com/playersong/561cb52/
        //http://www.goear.com/public/default/js/listen/listen.js?version=1.9.3
        //http://www.goear.com/externaltrackhost.php?f=e92bc21&cb=0.18596653640270233
        //http://www.goear.com/externaltrackhost.php?f=e92bc21&cb=0.18596653640270233
    }

    public function descarga() {
        View::select(NULL, NULL);
        $ruta = "http://live2.goear.com/listen/ea1de6ad46903677fee9c8a1af203873/51ed53a5/sst6/mp3files/28112010/02fcf24b969b9887a8bacd3a0d7167c1.mp3";
        $autor = "prueba";
        $ruta = str_replace(" ", "%20", $_GET['url']);
        $nombre = str_replace(" ", "%20", $_GET['title']);
        $autor = str_replace(" ", "%20", $_GET['autor']);
        $nombre = $nombre . "-" . $autor . "[descargatump3.com].mp3";
        header("Content-type: audio/mpeg");
        header("Content-Disposition: attachment; filename=" . $nombre . "");
        readfile($ruta);
    }

}

?>
